package com.college_career_system.controller;


import com.college_career_system.pojo.po.Resume;
import com.college_career_system.service.ResumeService;
import com.college_career_system.utils.Constant;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Empty
 * @since 2022-12-04
 */
@Controller
@RequestMapping("/resume")
@CrossOrigin(origins = Constant.URL, allowCredentials = "true", maxAge = 3600)
public class ResumeController {

    private final ResumeService resumeService;


    public ResumeController(ResumeService resumeService) {
        this.resumeService = resumeService;
    }

    /**
     * 添加简历，除了resume_id不用写，其他都要
     * @param request
     * @param resume
     * @return
     */
    @PostMapping("/addResume")
    @ResponseBody
    public String addResume(HttpServletRequest request, Resume resume){
        return resumeService.addResume(request, resume).toString();
    }

    /**
     * 获取自己的简历信息
     * @param request
     * @return
     */
    @PostMapping("/selectResumeByUid")
    @ResponseBody
    public String selectResumeByUid(HttpServletRequest request){
        return resumeService.selectResumeByUid(request).toString();
    }

    /**
     * 更新简历，简历id不能为空，其余的属性只要写自己需要变更的就行
     * @param resume
     * @return
     */
    @PostMapping("/changeResumeById")
    @ResponseBody
    public String changeResumeById(Resume resume){
        return resumeService.changeResumeById(resume).toString();
    }
}

